package haiyangwangwork.day11.homework.hk.邓仕卫;

import java.util.Scanner;

public class GetScores {
    //输入7位同学的成绩，找出最高分，最低分(冒泡排序)
    public static void main(String[] args) {

        String[] stuName = new String[7];
        double[] stuScores = new double[7];
        Scanner input = new Scanner(System.in);

        for (int i = 0; i < stuName.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位学生姓名：");
            stuName[i] = input.next();
            System.out.println("请输入学生成绩：");
            stuScores[i] = input.nextDouble();
        }
        for (int i = 0; i < stuScores.length - 1; i++) {

            for (int j = 0; j < stuScores.length - 1 - i; j++) {

                if (stuScores[j] < stuScores[j + 1]) {
                    double temp = stuScores[j];
                    stuScores[j] = stuScores[j + 1];
                    stuScores[j + 1] = temp;

                    String stuStr = stuName[j];
                    stuName[j] = stuName[j + 1];
                    stuName[j + 1] = stuStr;
                }

            }
        }

        double max = stuScores[0];
        double min = stuScores[6];
        for (double e : stuScores) {
            System.out.print(e + " ");
        }
        System.out.println('\n' + "最高分为" + stuName[0] + "," + max + "分");
        System.out.println("最低分为" + stuName[6] + "," + min + "分");

    }
}
